var root = ui("$");
var app = sm("do_App");
var do_Page = sm("do_Page");
var nf = sm("do_Notification");
var do_GridView_1 = ui("do_GridView_1");
var deviceone = require("deviceone");
var communityUrl = require("url/community");
var communityUtil = require("helper/community");
var httpUrl = communityUrl.url.message.del;
var qqHttp = require("helper/http");
var helperOpen = require("helper/open");

//UI
var buttonDel=ui("buttonDel");
var labelContent=ui("labelContent");
var messageImgsData;
//设置数据绑定的映射关系
root.setMapping({   // 此处的Mapping只能设置在 RootView 上 ;
	"UserName.text" : "creatorName",
    "UserPic.tag" : "creatorId",
    "UserPic.source" : "fullCreatorImg",
	"labelContent.tag" : "id",
    "labelContent.text" : "content",
    //"labelTime.text" : "dayMinutesNewAt",
    "labelTime.text" : "cnNewAt",
    "do_GridView_1.items" : "imgItems",
    "do_GridView_1.tag" : "bigImgItems",
    "do_GridView_1.visible" : "hasImg",
    "labelCommunityName.text":"communityName",
    "InforReply.text" : "commentCount",
    "InforZan.text" : "praiseCount"
});
var listdataImgs = mm("do_ListData");
root.on("dataRefreshed", function(){
})
//图片浏览注册事件
do_GridView_1.on("touch", function(data){
	helperOpen.open("source://view/reuse/imgBrowser.ui", {
		imgDatas :do_GridView_1.tag,index:data
	});
})

buttonDel.on("touch",function(){
	nf.confirm("您确实要删除这条记录吗？", "删除", "确定", "取消", function(data, e) {
		if(data == 1){
			delMessage();
		}
	})
})
function delMessage(){
	var params = {
		id: labelContent.tag
	};
	qqHttp.post(httpUrl, params, function(data) {
		nf.toast("删除成功");
		do_Page.fire("deleteMessage",labelContent.tag);
	})
}
ui("linearLayout_1").redraw();